﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ThucThe;
using DieuKhien;

namespace GiaoDien
{
    public partial class QL_NhanVien : Form
    {
        public QL_NhanVien()
        {
            InitializeComponent();
        }
        NhanVien_dieukhien nv_dk = new NhanVien_dieukhien();
        NhanVien_thucthe nv_tt = new NhanVien_thucthe();
        private void button_OK_Click(object sender, EventArgs e)
        {
            try
            {
                nv_tt.TenNhanVien = txt_tenNV.Text.Trim();
                if (rbtn_Nam.Checked)
                {
                    nv_tt.GioiTinh = true;
                }
                else
                {
                    nv_tt.GioiTinh = false;
                }
                nv_tt.MatKhau = txt_matKhau.Text.Trim();
                nv_tt.NgaySinh = dateTime_ngaySinh.Value.Date.ToShortDateString();
                nv_tt.Quyen = txt_quyen.Text.Trim();
                nv_tt.Sdt = msktxt_sdt.Text.Trim();
                nv_tt.Email = txt_Email.Text.Trim();
                nv_tt.ChucVu = txt_chucVu.Text.Trim();
                nv_tt.DiaChi = txt_diaChi.Text.Trim();
                nv_dk.themNhanVien(nv_tt);
                MessageBox.Show("Thêm thành công.");
                this.Close();
                QL frm_ql = new QL();
                frm_ql.Show();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Nhập đầy đủ các trường");
            }
            catch (FormatException)
            {
                MessageBox.Show("Nhập số cho số điện thoại");
            }
        }

        private void button_Reset_Click(object sender, EventArgs e)
        {
             txt_tenNV.Text = "";
             txt_matKhau.Text = "";
             dateTime_ngaySinh.Text = "";
             txt_quyen.Text = "";
             msktxt_sdt.Text = "";
             txt_Email.Text = "";
             txt_chucVu.Text = "";
             txt_diaChi.Text = "";
        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
